import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-10-31
 * Time: 19:08
 */
public class Demo2 {
    public static void main(String[] args) {
        Object object = new Object();
        Thread t1 = new Thread(() -> {
            try {
                System.out.println("t1释放锁前");
                synchronized(object) {
                    object.wait();
                }
                System.out.println("t1释放锁后");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        Thread t2 = new Thread(() -> {
            Scanner sc = new Scanner(System.in);
            System.out.println("输入任意内容唤醒t1线程:");
            sc.next();
            synchronized(object) {
                object.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
